<?php
// vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3 foldclose=all foldmethod=marker:
/**
 * 项目：   5anet
 * 文件：   class/article/ShowArticleIndex.class.php
 *
 * 显示文章管理的首页
 *
 * PHP Version 5
 *
 * @package:   class.article
 * @author:    Mike.G Chinese Name: 黄叶 <hylinux@gmail.com>
 * @license:   http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
 * @copyright: www.5anet.com
 * @version:   $Id: ShowArticleIndex.class.php,v 1.1 2006-09-24 14:38:33 ghw Exp $
 * @date:      $Date: 2006-09-24 14:38:33 $
 */

include_once CLASS_PATH.'main/BaseAction.class.php';

//包含我们需要的工具软件包
include_once CLASS_PATH.'article/CategoryUtil.class.php';
include_once CLASS_PATH.'article/ArticleUtil.class.php';



//include the language file
if ( file_exists(LANG_PATH.SYSTEM_LANG.'/ShowArticleIndex.lang.php') ) {
   include_once LANG_PATH.SYSTEM_LANG.'/ShowArticleIndex.lang.php';
}

//定义处理的类

class ShowArticleIndex extends BaseAction {

   /**
    * 数据库的连接
    */
   private $db;

   /**
    * 构造函数
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function __construct() {
      $this->db = $this->getDB();
   }


   /**
    * 显示文章管理的首页
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function run() {

      $smarty = $this->getSmarty();

      $categroy = CategoryUtil::getTopCategory($this->db);

      $categroy_id = array();

      for( $i=0; $i<6; $i++ ) {
         $categroy_id[$i] = $categroy[$i];
      }

      reset($categroy);

      for($i=0; $i<6; $i++ ) {
         $smarty->assign('top_'.($i+1).'_id', $categroy_id[$i]['id']);
         $smarty->assign('top_'.($i+1).'_name', $categroy_id[$i]['name']);
         $smarty->assign('top_'.($i+1).'_sname', $categroy_id[$i]['sname']);

         $tempArticle = ArticleUtil::getTopArticleFromCategory($this->db, $categroy_id[$i]['id']);

         $smarty->assign('top_'.($i+1).'_list', $tempArticle);

      }


      $smarty->assign('catagroy', $categroy);
      $smarty->assign('clone_title', '5anet.com' );
      $smarty->assign('header_meta_content', 'Linux, PHP, Perl, JAVA等资料收藏');

      //取得最近更新的文章
      $top_article = ArticleUtil::getTopArticleList($this->db);

      $smarty->assign('toparticle', $top_article);


      $smarty->display('articleindex.tmpl');

   }


}




?>
